package com.kk.xhr.model.dao;

import static com.kk.xhr.model.dao.SalaryDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.kk.xhr.model.entity.Salary;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface SalaryMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    BasicColumn[] selectList = BasicColumn.columnList(id, userId, basicSalary, bonus, workTime, absenceDay, lunchSalary, trafficSalary, finalSalary, pensionBase, pensionPercentage, medicalBase, medicalPercentage, accumulationFundBase, accumulationFundPercentage, individualTax, salaryTime, status, created, updated);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<Salary> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("SalaryResult")
    Optional<Salary> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="SalaryResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="basic_salary", property="basicSalary", jdbcType=JdbcType.BIGINT),
        @Result(column="bonus", property="bonus", jdbcType=JdbcType.BIGINT),
        @Result(column="work_time", property="workTime", jdbcType=JdbcType.DOUBLE),
        @Result(column="absence_day", property="absenceDay", jdbcType=JdbcType.INTEGER),
        @Result(column="lunch_salary", property="lunchSalary", jdbcType=JdbcType.BIGINT),
        @Result(column="traffic_salary", property="trafficSalary", jdbcType=JdbcType.BIGINT),
        @Result(column="final_salary", property="finalSalary", jdbcType=JdbcType.BIGINT),
        @Result(column="pension_base", property="pensionBase", jdbcType=JdbcType.BIGINT),
        @Result(column="pension_percentage", property="pensionPercentage", jdbcType=JdbcType.REAL),
        @Result(column="medical_base", property="medicalBase", jdbcType=JdbcType.BIGINT),
        @Result(column="medical_percentage", property="medicalPercentage", jdbcType=JdbcType.REAL),
        @Result(column="accumulation_fund_base", property="accumulationFundBase", jdbcType=JdbcType.BIGINT),
        @Result(column="accumulation_fund_percentage", property="accumulationFundPercentage", jdbcType=JdbcType.REAL),
        @Result(column="individual_tax", property="individualTax", jdbcType=JdbcType.DOUBLE),
        @Result(column="salary_time", property="salaryTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="created", property="created", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updated", property="updated", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Salary> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, salary, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, salary, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default int insert(Salary record) {
        return MyBatis3Utils.insert(this::insert, record, salary, c ->
            c.map(userId).toProperty("userId")
            .map(basicSalary).toProperty("basicSalary")
            .map(bonus).toProperty("bonus")
            .map(workTime).toProperty("workTime")
            .map(absenceDay).toProperty("absenceDay")
            .map(lunchSalary).toProperty("lunchSalary")
            .map(trafficSalary).toProperty("trafficSalary")
            .map(finalSalary).toProperty("finalSalary")
            .map(pensionBase).toProperty("pensionBase")
            .map(pensionPercentage).toProperty("pensionPercentage")
            .map(medicalBase).toProperty("medicalBase")
            .map(medicalPercentage).toProperty("medicalPercentage")
            .map(accumulationFundBase).toProperty("accumulationFundBase")
            .map(accumulationFundPercentage).toProperty("accumulationFundPercentage")
            .map(individualTax).toProperty("individualTax")
            .map(salaryTime).toProperty("salaryTime")
            .map(status).toProperty("status")
            .map(created).toProperty("created")
            .map(updated).toProperty("updated")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default int insertSelective(Salary record) {
        return MyBatis3Utils.insert(this::insert, record, salary, c ->
            c.map(userId).toPropertyWhenPresent("userId", record::getUserId)
            .map(basicSalary).toPropertyWhenPresent("basicSalary", record::getBasicSalary)
            .map(bonus).toPropertyWhenPresent("bonus", record::getBonus)
            .map(workTime).toPropertyWhenPresent("workTime", record::getWorkTime)
            .map(absenceDay).toPropertyWhenPresent("absenceDay", record::getAbsenceDay)
            .map(lunchSalary).toPropertyWhenPresent("lunchSalary", record::getLunchSalary)
            .map(trafficSalary).toPropertyWhenPresent("trafficSalary", record::getTrafficSalary)
            .map(finalSalary).toPropertyWhenPresent("finalSalary", record::getFinalSalary)
            .map(pensionBase).toPropertyWhenPresent("pensionBase", record::getPensionBase)
            .map(pensionPercentage).toPropertyWhenPresent("pensionPercentage", record::getPensionPercentage)
            .map(medicalBase).toPropertyWhenPresent("medicalBase", record::getMedicalBase)
            .map(medicalPercentage).toPropertyWhenPresent("medicalPercentage", record::getMedicalPercentage)
            .map(accumulationFundBase).toPropertyWhenPresent("accumulationFundBase", record::getAccumulationFundBase)
            .map(accumulationFundPercentage).toPropertyWhenPresent("accumulationFundPercentage", record::getAccumulationFundPercentage)
            .map(individualTax).toPropertyWhenPresent("individualTax", record::getIndividualTax)
            .map(salaryTime).toPropertyWhenPresent("salaryTime", record::getSalaryTime)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(created).toPropertyWhenPresent("created", record::getCreated)
            .map(updated).toPropertyWhenPresent("updated", record::getUpdated)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default Optional<Salary> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, salary, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default List<Salary> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, salary, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default List<Salary> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, salary, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default Optional<Salary> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, salary, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    static UpdateDSL<UpdateModel> updateAllColumns(Salary record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(userId).equalTo(record::getUserId)
                .set(basicSalary).equalTo(record::getBasicSalary)
                .set(bonus).equalTo(record::getBonus)
                .set(workTime).equalTo(record::getWorkTime)
                .set(absenceDay).equalTo(record::getAbsenceDay)
                .set(lunchSalary).equalTo(record::getLunchSalary)
                .set(trafficSalary).equalTo(record::getTrafficSalary)
                .set(finalSalary).equalTo(record::getFinalSalary)
                .set(pensionBase).equalTo(record::getPensionBase)
                .set(pensionPercentage).equalTo(record::getPensionPercentage)
                .set(medicalBase).equalTo(record::getMedicalBase)
                .set(medicalPercentage).equalTo(record::getMedicalPercentage)
                .set(accumulationFundBase).equalTo(record::getAccumulationFundBase)
                .set(accumulationFundPercentage).equalTo(record::getAccumulationFundPercentage)
                .set(individualTax).equalTo(record::getIndividualTax)
                .set(salaryTime).equalTo(record::getSalaryTime)
                .set(status).equalTo(record::getStatus)
                .set(created).equalTo(record::getCreated)
                .set(updated).equalTo(record::getUpdated);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Salary record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(userId).equalToWhenPresent(record::getUserId)
                .set(basicSalary).equalToWhenPresent(record::getBasicSalary)
                .set(bonus).equalToWhenPresent(record::getBonus)
                .set(workTime).equalToWhenPresent(record::getWorkTime)
                .set(absenceDay).equalToWhenPresent(record::getAbsenceDay)
                .set(lunchSalary).equalToWhenPresent(record::getLunchSalary)
                .set(trafficSalary).equalToWhenPresent(record::getTrafficSalary)
                .set(finalSalary).equalToWhenPresent(record::getFinalSalary)
                .set(pensionBase).equalToWhenPresent(record::getPensionBase)
                .set(pensionPercentage).equalToWhenPresent(record::getPensionPercentage)
                .set(medicalBase).equalToWhenPresent(record::getMedicalBase)
                .set(medicalPercentage).equalToWhenPresent(record::getMedicalPercentage)
                .set(accumulationFundBase).equalToWhenPresent(record::getAccumulationFundBase)
                .set(accumulationFundPercentage).equalToWhenPresent(record::getAccumulationFundPercentage)
                .set(individualTax).equalToWhenPresent(record::getIndividualTax)
                .set(salaryTime).equalToWhenPresent(record::getSalaryTime)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(created).equalToWhenPresent(record::getCreated)
                .set(updated).equalToWhenPresent(record::getUpdated);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default int updateByPrimaryKey(Salary record) {
        return update(c ->
            c.set(userId).equalTo(record::getUserId)
            .set(basicSalary).equalTo(record::getBasicSalary)
            .set(bonus).equalTo(record::getBonus)
            .set(workTime).equalTo(record::getWorkTime)
            .set(absenceDay).equalTo(record::getAbsenceDay)
            .set(lunchSalary).equalTo(record::getLunchSalary)
            .set(trafficSalary).equalTo(record::getTrafficSalary)
            .set(finalSalary).equalTo(record::getFinalSalary)
            .set(pensionBase).equalTo(record::getPensionBase)
            .set(pensionPercentage).equalTo(record::getPensionPercentage)
            .set(medicalBase).equalTo(record::getMedicalBase)
            .set(medicalPercentage).equalTo(record::getMedicalPercentage)
            .set(accumulationFundBase).equalTo(record::getAccumulationFundBase)
            .set(accumulationFundPercentage).equalTo(record::getAccumulationFundPercentage)
            .set(individualTax).equalTo(record::getIndividualTax)
            .set(salaryTime).equalTo(record::getSalaryTime)
            .set(status).equalTo(record::getStatus)
            .set(created).equalTo(record::getCreated)
            .set(updated).equalTo(record::getUpdated)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: salary")
    default int updateByPrimaryKeySelective(Salary record) {
        return update(c ->
            c.set(userId).equalToWhenPresent(record::getUserId)
            .set(basicSalary).equalToWhenPresent(record::getBasicSalary)
            .set(bonus).equalToWhenPresent(record::getBonus)
            .set(workTime).equalToWhenPresent(record::getWorkTime)
            .set(absenceDay).equalToWhenPresent(record::getAbsenceDay)
            .set(lunchSalary).equalToWhenPresent(record::getLunchSalary)
            .set(trafficSalary).equalToWhenPresent(record::getTrafficSalary)
            .set(finalSalary).equalToWhenPresent(record::getFinalSalary)
            .set(pensionBase).equalToWhenPresent(record::getPensionBase)
            .set(pensionPercentage).equalToWhenPresent(record::getPensionPercentage)
            .set(medicalBase).equalToWhenPresent(record::getMedicalBase)
            .set(medicalPercentage).equalToWhenPresent(record::getMedicalPercentage)
            .set(accumulationFundBase).equalToWhenPresent(record::getAccumulationFundBase)
            .set(accumulationFundPercentage).equalToWhenPresent(record::getAccumulationFundPercentage)
            .set(individualTax).equalToWhenPresent(record::getIndividualTax)
            .set(salaryTime).equalToWhenPresent(record::getSalaryTime)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(created).equalToWhenPresent(record::getCreated)
            .set(updated).equalToWhenPresent(record::getUpdated)
            .where(id, isEqualTo(record::getId))
        );
    }
}